package com.atguigu.school.controller;

import com.atguigu.school.commons.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 全局异常处理器
 *
 * @author 刘逸晖
 */
@ApiIgnore
@ControllerAdvice
public class ExceptionController {

    /**
     * 处理所有异常
     *
     * @param exception 抛出的异常
     * @return 错误反馈
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result<?> handleException(Exception exception) {
        return Result.fail()
                .message("服务器繁忙，请稍后再试");
    }

}
